﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;

namespace K3R.Generics {
	[DataContract]
	public class SerializableKeyValuePair<TKey, TValue> {
		[DataMember(Name = "key")] public TKey Key { get; set; }
		[DataMember(Name = "value")] public TValue Value { get; set; }

		public static List<SerializableKeyValuePair<TKey, TValue>> Convert(IDictionary<TKey, TValue> dictionary) {
			var list = new List<SerializableKeyValuePair<TKey, TValue>>();

			foreach (var item in dictionary)
				list.Add(new SerializableKeyValuePair<TKey, TValue> {
					Key = item.Key,
					Value = item.Value
				});

			return list;
		}
	}
}
